package com.zut.yunxi.yunxi.service.impl;

import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zut.yunxi.yunxi.dao.OauthClientDetailsDao;
import com.zut.yunxi.yunxi.entity.OauthClientDetailsEntity;
import com.zut.yunxi.yunxi.service.OauthClientDetailsService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("oauthClientDetailsService")
public class OauthClientDetailsServiceImpl extends ServiceImpl<OauthClientDetailsDao, OauthClientDetailsEntity> implements OauthClientDetailsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<OauthClientDetailsEntity> queryWrapper=new QueryWrapper<OauthClientDetailsEntity>();
        if(StringUtils.isNotBlank(key))
        {
            queryWrapper.eq("client_id",key).or().like("client_secret",key);
        }
        IPage<OauthClientDetailsEntity> page = this.page(
                new Query<OauthClientDetailsEntity>().getPage(params),
                queryWrapper

        );

        return new PageUtils(page);
    }

}